package org.yoshiori.lingr.bot.utils;

import org.apache.commons.lang.StringUtils;
import org.yoshiori.lingr.api.Message;
import org.yoshiori.lingr.api.ObserveEvent;
import org.yoshiori.lingr.api.vo.ClientType;
import org.yoshiori.lingr.bot.LingrBot;
import org.yoshiori.lingr.bot.ObserverListener;

public abstract class SimpleObserver implements ObserverListener {

	public void observe(LingrBot lingrBot, ObserveEvent event) {
		for (Message message : event.getMessages()) {
			if (message.getClientType() == ClientType.HUMAN) {
				String text = say(message);
				if(StringUtils.isNotEmpty(text)){
					lingrBot.say(text);
				}
			}
		}
	}

	public abstract String say(Message message);
}
